#!/bin/sh
# This should be written for a classic Bourne shell.  Therefore avoid
# things like $() and other bash-isms and ksh-isms that don't work
# with a classic Bourne shell.
top_srcdir=`(cd \`dirname $0\` > /dev/null 2>&1 ; pwd)`
MAXIMA_PREFIX="$top_srcdir"
export MAXIMA_PREFIX
MAXIMA_LAYOUT_AUTOTOOLS=false
export MAXIMA_LAYOUT_AUTOTOOLS
MAXIMA_OBJDIR="$top_srcdir/binary"
export MAXIMA_OBJDIR

# report the compiled in Lisp versions
if [ x"$1" = "x--list-avail" ]; then
    V=`./maxima-local --version | sed s/Maxima.//`
    echo "Available versions:"
    for i in src/binary-* ; do
        L=`echo $i | sed s/src.binary-//`
        echo "version $V, lisp $L"
    done;
    exit;
fi;

# quick fix for plotting with plot_format=openmath (bug 3052)
if [ ! -d "$top_srcdir/bin" ]; then
    mkdir -p "$top_srcdir/bin"
    ln -sf "$top_srcdir/xmaxima-local" "$top_srcdir/bin/xmaxima"
    ln -sf "$top_srcdir/doc" "$top_srcdir/bin/doc"
    ln -sf "$top_srcdir/src" "$top_srcdir/bin/src"
    ln -sf "$top_srcdir/interfaces" "$top_srcdir/bin/interfaces"
fi

POSIX_SHELL=@POSIX_SHELL@
exec $POSIX_SHELL "$top_srcdir/src/maxima" "$@"
